package com.xiaoshuidi.cloud.module.rooms.service.impl;

import cn.hutool.core.util.StrUtil;
import com.xiaoshuidi.cloud.module.rooms.controller.admin.roomapartmentarea.vo.FuzzyQueryByAreaBuildingUnitVO;
import com.xiaoshuidi.cloud.module.rooms.pojo.RoomApartmentArea;
import com.xiaoshuidi.cloud.module.rooms.mapper.RoomApartmentAreaMapper;
import com.xiaoshuidi.cloud.module.rooms.repository.RoomApartmentAreaRepository;
import com.xiaoshuidi.cloud.module.rooms.service.IRoomApartmentAreaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 公寓下的小区 服务实现类
 * </p>
 *
 * @author hans.zhang
 * @since 2023-05-11
 */
@Service
@RequiredArgsConstructor
public class RoomApartmentAreaServiceImpl extends ServiceImpl<RoomApartmentAreaMapper, RoomApartmentArea> implements IRoomApartmentAreaService {

    private final RoomApartmentAreaRepository roomApartmentAreaRepository;

    /**
     * 根据小区楼栋单元名模糊查询楼栋单元信息
     * @param searchBox
     * @param apartmentId
     * @return
     */
    @Override
    public List<FuzzyQueryByAreaBuildingUnitVO> fuzzyQueryByAreaBuildingUnit(String searchBox, Long apartmentId) {
        if(StrUtil.isEmpty(searchBox)){
            return new ArrayList<>();
        }
        return roomApartmentAreaRepository.fuzzyQueryByAreaBuildingUnit(searchBox, apartmentId);
    }
}
